import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

void main() {
  runApp(MaterialApp(home: TextHomePage()));
}

class TextHomePage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return TextHomePageState();
  }
}

class TextHomePageState extends State {
  int? selectedValue;

  @override
  Widget build(BuildContext context) {
    /**
     * Listview
     * 默认构造方法：listview
     *
     *ListView(
        scrollDirection: Axis.vertical,
        itemExtent: 90,
        children: List.generate(100, (index) {
        return
        //    创建最普通的listview
        // Column(
        //   crossAxisAlignment: CrossAxisAlignment.start,
        //   children: [
        //   SizedBox(height: 10,),Text("asdf")
        //   ],
        // );
        ListTile(
        leading:Icon(Icons.favorite) , //item的头部
        trailing:Icon(Icons.landscape_outlined),//item的尾部
        title: Text("wenben"), //item的标题
        subtitle:Text("asdf") ,//item的内容
        );
        }
        )
        )

     * Listview.build()
     *
     * ListView.builder(
        itemCount: 100,
        itemBuilder: (BuildContext context, int index) {
        return //这里的return实际上是返回widget（视图）
        ListTile(
        leading:Icon(Icons.favorite) , //item的头部
        trailing:Icon(Icons.landscape_outlined),//item的尾部
        title: Text("wenben"), //item的标题
        subtitle:Text("asdf") ,//item的内容
        );
        },
        )


     * Listview.separated
     *
     * ListView.separated(
        itemBuilder: (BuildContext context,int index){
        return const ListTile(
        leading:Icon(Icons.favorite) , //item的头部
        trailing:Icon(Icons.landscape_outlined),//item的尾部
        title: Text("wenben"), //item的标题
        subtitle:Text("asdf") ,//item的内容
        );
        },
        separatorBuilder: (BuildContext context,int index){  //该方法用来设置底线
        return const Divider(
        color: Colors.red,
        height: 10,
        indent: 30,  //底线距离屏幕左面的距离
        endIndent: 30, //底线距离屏幕右面的距离
        );
        },
        itemCount: 100, //设置列表条数
        )
     *
     *
     * Listview.custom
     *
     * GridView
     *
     *
     * sliver
     *
     *
     *
     * 滚动的监听
     */
    return MaterialApp(
      home: Scaffold(
          appBar: AppBar(
            title: Text("listview"),
          ),
          body: ListView.separated(
            itemBuilder: (BuildContext context,int index){
              return const ListTile(
                leading:Icon(Icons.favorite) , //item的头部
                trailing:Icon(Icons.landscape_outlined),//item的尾部
                title: Text("wenben"), //item的标题
                subtitle:Text("asdf") ,//item的内容
              );
            },
            separatorBuilder: (BuildContext context,int index){  //该方法用来设置底线
              return const Divider(
                color: Colors.red,
                height: 10,
                indent: 30,  //底线距离屏幕左面的距离
                endIndent: 30, //底线距离屏幕右面的距离
              );
            },
            itemCount: 100, //设置列表条数
          )
      ),
    );
  }
}
